﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using ConstructionBidOnline.Biz;

public partial class ContractorSearchPageMasterPage : System.Web.UI.MasterPage
{
    #region Constants

    private const string PROP_DATASRC_JOBCATEGORY = "__JobCategory::JC";
    private const string PROP_SELECTED_JOBCATEGORY_ID = "__JobCategory::SJCID";
    private const string PROP_DATASRC_JOBS_JOBCATEGORY = "__Jobs_JobCategory::J_JC";

    #endregion

    #region Public Properties

    public JobCollection DataSourceJobs_JobCategory
    {
        get { return (SessionMgr.Session[PROP_DATASRC_JOBS_JOBCATEGORY] is JobCollection ? (JobCollection)SessionMgr.Session[PROP_DATASRC_JOBS_JOBCATEGORY] : (JobCollection)(SessionMgr.Session[PROP_DATASRC_JOBS_JOBCATEGORY] = new JobCollection())); }
        set { SessionMgr.Session[PROP_DATASRC_JOBS_JOBCATEGORY] = value; }
    }

    public JobCategoryCollection DataSourceJobCategory
    {
        get { return (SessionMgr.Session[PROP_DATASRC_JOBCATEGORY] is JobCategoryCollection ? (JobCategoryCollection)SessionMgr.Session[PROP_DATASRC_JOBCATEGORY] : (JobCategoryCollection)(SessionMgr.Session[PROP_DATASRC_JOBCATEGORY] = new JobCategoryCollection())); }
        set { SessionMgr.Session[PROP_DATASRC_JOBCATEGORY] = value; }
    }

    public int SelectedJobCategoryID
    {
        get { return (SessionMgr.Session[PROP_SELECTED_JOBCATEGORY_ID] is int ? (int)SessionMgr.Session[PROP_SELECTED_JOBCATEGORY_ID] : 0); }
        set { SessionMgr.Session[PROP_SELECTED_JOBCATEGORY_ID] = value; }
    }


    #endregion

    #region Event Handlers

    #region Page Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        if (!Page.IsPostBack)
        {
            if (Session["username"] == null)
            {
                Response.Redirect("../sessionexpire.aspx");
            }
            else
            {
                RegisteredUser BuyerObj = RegisteredUser.GetUserByUserName(Session["username"].ToString());
                Session["currentuserid"] = BuyerObj.RegisteredUserID;
                lblusername.Text = BuyerObj.UserName;
                JobCollection JobCollectionObj = Job.GetJobByUserID(BuyerObj.RegisteredUserID);
                if (JobCollectionObj.Count > 0)
                    lblprojectpostedcount.Text = JobCollectionObj.Count.ToString();
                else
                    lblprojectpostedcount.Text = "0";



                DataSourceJobCategory = JobCategory.GetAllJobCategories();
                DataSourceJobs_JobCategory = Job.GetAllJob();
            }
        }

    }

    #endregion

    #endregion
}
